//
//  eatMedicineOfNumberTableViewCell.m
//  myMedicine1.0
//
//  Created by pollysoft on 16/8/4.
//  Copyright © 2016年 microi. All rights reserved.
//

#import "eatMedicineOfNumberTableViewCell.h"
@implementation eatMedicineOfNumberTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
     _medicineNumber.text = [NSString stringWithFormat:@"%ld",self.eatMedicineNumber];
    // Initialization code
}
#pragma mark – lazy loading
-(MedicineListTableViewController *)medicineList{
    if (!_medicineList) {
        _medicineList = [[MedicineListTableViewController alloc]init];
    }
    return _medicineList;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)addNumberButton:(id)sender {
    
    if ( self.eatMedicineNumber == 0) {
        self.eatMedicineNumber = 1;
    }

    if (self.eatMedicineNumber >= 1 && self.eatMedicineNumber < 8) {
        self.eatMedicineNumber ++;
        
        _medicineNumber.text = [NSString stringWithFormat:@"%ld",self.eatMedicineNumber];
        
        if ( self.eatMedicineOfNumberDalegate != nil && [self.eatMedicineOfNumberDalegate respondsToSelector:@selector(refreshEatMedicineOfNumber:and:)]) {
            
            [self.eatMedicineOfNumberDalegate refreshEatMedicineOfNumber:self.eatMedicineNumber and:_indexPath];
            
        }
    }

    
    
}

- (IBAction)reduceNumberButton:(id)sender {
    
    if ( self.eatMedicineNumber == 0) {
        self.eatMedicineNumber = 1;
    }
    if (self.eatMedicineNumber > 1 && self.eatMedicineNumber <= 8) {
        self.eatMedicineNumber --;
        
        _medicineNumber.text = [NSString stringWithFormat:@"%ld",self.eatMedicineNumber];

        if ( self.eatMedicineOfNumberDalegate != nil && [self.eatMedicineOfNumberDalegate respondsToSelector:@selector(refreshEatMedicineOfNumber:and:)]) {
            
            [self.eatMedicineOfNumberDalegate refreshEatMedicineOfNumber:self.eatMedicineNumber and:_indexPath];
            
        }
    }


}
@end
